package com.founder.gateway.system.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class JSONUtil {
    public static JSONObject jsonPeeling(JSONObject json, String... names) {
        for (String name : names) {
            Object object = json.get(name);
            if (object instanceof JSONObject) {
                json = (JSONObject) object;
            } else {
                return null;
            }
        }
        return json;
    }

    public static String toString(Object object) {
        return object == null ? null : JSON.toJSONString(object);
    }
}
